package gupiao.cn.lhl.service.impl;

import gupiao.cn.lhl.dao.IAccountDao;
import gupiao.cn.lhl.dao.IStuckDao;
import gupiao.cn.lhl.entity.Account;
import gupiao.cn.lhl.entity.Stuck;
import gupiao.cn.lhl.entity.StuckException;
import gupiao.cn.lhl.service.IGupiaoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by Administrator on 2017/4/2/002.
 */
@Service("service")
public class GupiaoServiceImpl implements IGupiaoService {
    @Resource
    IAccountDao accountDao;
    @Resource
    IStuckDao stuckDao;

    public int addAccount(Account account) {
        return accountDao.addAccount( account);
    }


    public int addStuck(Stuck stuck) {
        return stuckDao.addStuck( stuck);
    }

    public int updateGupiao(int aid, int sid, double maney, int count, boolean is) throws StuckException {
        accountDao.updateAccount(maney,aid,is);
        if (1 == 1) {
            throw new StuckException("报错了，啦啦啦啦啦啦！！！！！！");
        }

        stuckDao.updateStuck(count,sid,is);
        return 0;
    }
}
